package com.example.myapplication2003;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class BActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bactivity);

        Button button = findViewById(R.id.btn);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 跳转activity
//                Intent intent =
//                        new Intent(BActivity.this, FragmentTestActivity.class);
//                startActivity(intent);

                Intent intent = new Intent();
                intent.putExtra("title", "Android");
                intent.putExtra("num", 111);
                setResult(100, intent);    // 设置返回的数据（intent对象）

                finish();    // 结束当前activity
            }
        });
    }
}